<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    	<link rel="stylesheet" href="css/cart.css" type="text/css" />
        <link rel="stylesheet" href="css/hqk_css.css" type="text/css" />
        <link rel="stylesheet" href="css/hqk_css_print.css" type="text/css" media="print" />
        <title>In đơn đặt hàng - Tranh thêu Nam Phương</title>
    </head>
    <body>
    	<?php
			include_once('libs/htdu_core.php');
			@$idorder = $_GET['code'];
			$exec_mysql = new execute_mysql_query();
			$global = new global_function();
			$get_order = $exec_mysql->execute("select full_name, address, email, phone, orders_date from orders where code = '$idorder'", 0);
			$cty_name = $exec_mysql->execute("select val from extra where ref= 'cty_name'", 1);
			$cty_address = $exec_mysql->execute("select val from extra where ref= 'cty_address'", 1);
			$phone = $exec_mysql->execute("select val from extra where ref= 'hot_line'", 1);
			
			echo '<div class="logo">';
			echo '<img src="img/logo.png" width="50px">';
			echo '</div>';
			echo '<div class="info">';
			echo '<b>'.$cty_name.'</b><br>';
			echo $cty_address."<br>";
			echo 'ĐT: '.$phone;
			echo "</div>";
			
			echo '<p class="tenphieu">ĐƠN ĐẶT HÀNG</p>';
			while($row_order = mysql_fetch_array($get_order))
			{
				echo '<table border="0px" cellpadding="2" cellspacing="2">';
				echo '<tr>';
				echo '<td>Họ tên:</td>';
				echo '<td><b>'.$row_order['full_name'].'</b></td>';
				echo '</tr>';
				echo '<tr>';
				echo '<td>Địa chỉ:</td>';
				echo '<td><b>'.$row_order['address'].'</b></td>';
				echo '</tr>';
				echo '<tr>';
				echo '<td>E-Mail:</td>';
				echo '<td><b>'.$row_order['email'].'</b></td>';
				echo '</tr>';
				echo '<tr>';
				echo '<td>Điện thoại: </td>';
				echo '<td><b>'.$row_order['phone'].'</b></td>';
				echo '</tr>';
				echo '<tr>';
				echo '<td>Ngày đặt hàng: </td>';
				echo '<td><b>'.$row_order['orders_date'].'</b></td>';
				echo '</tr>';
				echo '</table>';
			
				$get_product = $exec_mysql->execute("select orders_code,quantity,code,name,price from orders_detail, product where id_product=product.id and orders_code='$idorder'",0);
				
				echo '<table width="100%" class="table-list">';
				$index = 1;
				$total_money = 0;
				echo '<tr class="table-header"><td><b>STT</b></td><td><b>Mã tranh</b></td><td><b>Tên tranh</b></td><td><b>Số lượng</b></td><td><b>Đơn giá</b><sup>(VNĐ)</sup></td><td><b>Thành tiền</b><sup>(VNĐ)</sup></td></tr>';
				while($list_product = mysql_fetch_array($get_product))
				{
					echo '<tr>';
					echo '<td align="center">'.$index.'</td>';
					echo '<td>'.$list_product['code'].'</td>';
					echo '<td>'.$list_product['name'].'</td>';
					echo '<td align="right">'.$list_product['quantity'].'</td>';
					echo '<td align="right">'.$global->format_number($list_product['price'], 0).'</td>';
					$money = $list_product['price']*$list_product['quantity'];
					$total_money += $money;
					echo '<td align="right">'.$global->format_number($money, 0).'</td>';
					echo '</tr>';
					$index++;
				}
				echo '<tr class="table-footer"><td colspan="5" align="right">Tổng tiền*</td><td align="right">'.number_format($total_money, 0, ',', '.').'</td></tr>';
				echo '</table>';
				
			}
			?>
			<center><div class="print_view"><a href="javascript:print()"><img src="img/ic_printer.png" border="0" title="In đơn đặt hàng" /></a></div></center>
    </body>
</html>
